package com.tfswx.fljdmxyy.api;

import com.tfswx.fljdmxyy.dto.rwpz.*;
import com.tfswx.fljdmxyy.query.rwrz.RwrzQueryParam;
import com.tfswx.fljdmxyy.query.rwrz.RwrzQueryResult;
import com.tfswx.fljdmxyy.query.rwpz.RwpzQueryParam;
import com.tfswx.fljdmxyy.query.rwpz.RwpzQueryResult;
import com.tfswx.fljdmxyy.service.RwglService;
import com.tfswx.newbie.boot.starter.page.PageParam;
import com.tfswx.newbie.boot.starter.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 任务管理表
 *
 * @author: 陈文佳
 * @date: 2022-10-24
 **/
@Slf4j
@RestController
@RequestMapping(value = "api/rwgl")
@Api(tags = "任务管理表")
public class RwglController {

    @Resource
    private RwglService rwglService;

    @ApiOperation("新增任务管理表")
    @PostMapping(value = "/addRwpz")
    public RwpzAddOutputDTO addRwpz(@RequestBody @Validated RwpzAddInputDTO dto) {
        return rwglService.addRwpz(dto);
    }

    @ApiOperation("修改任务管理表")
    @PostMapping(value = "/updateRwpz")
    public Boolean updateRwpz(@RequestBody @Validated RwpzUpdateInputDTO dto) {
        return rwglService.updateRwpz(dto);
    }

    @ApiOperation("获取任务管理表")
    @PostMapping(value = "/getRwpz")
    public RwpzGetOutputDTO getRwpz(@RequestBody @Validated RwpzGetInputDTO dto) {
        return rwglService.getRwpz(dto);
    }

    @ApiOperation("删除任务管理表")
    @PostMapping(value = "/deleteRwpz")
    public Boolean deleteRwpz(@RequestBody @Validated RwpzDeleteInputDTO dto) {
        return rwglService.deleteRwpz(dto);
    }

    @ApiOperation("获取列表任务管理表")
    @PostMapping(value = "/queryRwpz")
    public PageResult<RwpzQueryResult> queryRwpz(@RequestBody @Validated PageParam<RwpzQueryParam> param) {
        return rwglService.queryRwpz(param);
    }

    @ApiOperation("执行定时任务（手动）")
    @PostMapping(value = "/executeRw")
    public Boolean executeRw(@RequestBody @Validated RwpzGetInputDTO dto) {
        return rwglService.executeRw(dto);
    }

    @ApiOperation("清空任务日志")
    @PostMapping(value = "/clearRwrz")
    public Boolean clearRwrz() {
        return rwglService.clearRwrz();
    }

    @ApiOperation("获取列表任务日志")
    @PostMapping(value = "/queryRwrz")
    public PageResult<RwrzQueryResult> queryRwrz(@RequestBody @Validated PageParam<RwrzQueryParam> param) {
        return rwglService.queryRwrz(param);
    }
}
